/*
  Name: serveur.h
  Copyright: none
  Author: ghannam
  Date: 14/10/06 10:34
  Description: 
*/
#ifndef __wServer_h__ 
#define __wServer_h__ 

#include <winsock2.h>
#include   <ctype.h>
#include  <time.h>

class wServer;

struct thread_param{
       wServer* ser;
       SOCKET soc;
};


class wServer{
	private: 

		int           port;  // numero port d'ecoute du serveur 
		SOCKET	      ListeningSocket; //socket d'ecoute
		bool          running;    // etat du serveur 
		SOCKADDR_IN   ServerAddr;       
		DWORD         ClientThread(SOCKET);  
		DWORD         TimerThread(void); 
		
		
	public:                                        
		wServer(int);
		int                 init();
		int                 demarrer ();  
		int                 pause ();
		
	// partie thread ...........
    
    	
	static DWORD WINAPI ThreadLauncher(void *p){
			struct thread_param *Obj = reinterpret_cast<struct thread_param*>(p);               
			wServer *s = Obj->ser;                          
			return s->ClientThread(Obj->soc);       
		}
		
		static DWORD WINAPI ThreadTimer(void *p){
			struct thread_param *Obj = reinterpret_cast<struct thread_param*>(p);               
			wServer *s = Obj->ser;                          
			return s->TimerThread();       
		}
}; 



#endif
